<?php
/**
 * @Copyright   2008, XXXX-XXXX
 * All rights reserved. 
 * feature summary.
 * @filesource  command.php 
 * @author      lipeng <lipengage@gmain.com> 
 * @package     / 
 * @version     $Id: $ 
 */

/*
 * a base class handler the command
 */
abstract class command {
	public static $BUY = "buy";
	public static $RELEASE = "releaseslave";
	public static $BUY_FROM_YOU = "buyfromyou";
	public static $RANSOM = "ransom";
	public static $INIT_PLAYER = "initplayer";
	public static $CANT_BUY_MASTER = "cantbuymaster";
	public static $ALREADY_HAVE_SLAVE = "alreadyhaveslave";
	public static $NOT_ENOUGH_MONEY = "notenoughmoney";
	public static $SLAVE_AT_WORK = "slaveatwork";
	public static $NOT_YOUR_SLAVE = "notyourslave";
	public static $DONT_HAVE_MASTER = "donthavemaster";
	public static $ALREADY_HAVE_PLAYER = "alreadyhaveplayer";
	public static $PLAYER_NOT_FOUND = "playernotfound";
	public static $PARAM_ERROR = "paramerror";

	public $response;
	public $request;
	public $config;
	public $catalog;

	public function __construct(&$catalog, &$config, &$request, &$response) {
		$this->catalog = &$catalog;
		$this->config = &$config;
		$this->request = &$request;
		$this->response = &$response;
	}

	//public function set_	public $params;

	public function set_response($key, $value) {
		$this->response[$key] = $value;
	}

	public function set_haserror($value) {
		$this->response["hasError"] = $value;
	}

	public function set_data($key, $value) {
		if ($key) {
			$this->response["data"][$key] = $value;
		}
		else {
			$this->response["data"] = $value;
		}
	}
	
	public function set_messageid($value) {
		$this->response["data"]["messageId"] = $value;
	}
	
	public function set_params($value) {
		if (!is_array($this->response["data"]["params"]))  {
			$this->response["data"]["params"] = array();
		}
		$this->response["data"]["params"] = array_merge($this->response["data"]["params"], $value);
	}

	abstract public function excute();
}
?>
